Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgrading indices which use a custom similarity plugin. #26985

Merged
merged 4 commits into from
Jan 9, 2018

Conversation

xabbu42
Copy link
Contributor

@xabbu42 xabbu42 commented Oct 12, 2017

Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have two small requests.


@Override
public Set<Entry<String, SimilarityProvider.Factory>> entrySet() {
return Collections.emptySet();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize the analyzer hack does this, but it is inconsistent with what is returned above. I would rather throw a UEO here so that if entrySet begins to be used, we will catch this rather than get weird behavior. (And we should, in a followup or in this PR, fix the other entrySet() impl as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that but need to know what an UEO is (I'm not a Java programmer).

Copy link
Member

@jasontedor jasontedor Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbu42 I think that @rjernst meant "UOE" as in UnsupportedOperationException.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Jason is correct on what I meant.

Copy link
Contributor Author

@xabbu42 xabbu42 Oct 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get test failures if make this change. For example:

Suite: org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeServiceTests
  1> [2017-10-14T16:43:29,230][INFO ][o.e.c.m.MetaDataIndexUpgradeServiceTests] [testPluginUpgradeFailure]: before test
  1> [2017-10-14T16:43:29,233][INFO ][o.e.c.m.MetaDataIndexUpgradeServiceTests] [testPluginUpgradeFailure]: after test
  2> REPRODUCE WITH: gradle :core:test -Dtests.seed=67F6816A4DF09ADB -Dtests.class=org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeServiceTests -Dtests.method="testPluginUpgradeFailure" -Dtests.security.manager=true -Dtests.locale=sr -Dtests.timezone=Asia/Katmandu
FAILURE 0.03s | MetaDataIndexUpgradeServiceTests.testPluginUpgradeFailure <<< FAILURES!
   > Throwable #1: org.junit.ComparisonFailure: expected:<[unable to upgrade the mappings for the index [[foo/BOOM]]]> but was:<[Cannot upgrade index foo]>
   >    at __randomizedtesting.SeedInfo.seed([67F6816A4DF09ADB:37D52F4B7D45621E]:0)
   >    at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeServiceTests.testPluginUpgradeFailure(MetaDataIndexUpgradeServiceTests.java:141)
   >    at java.lang.Thread.run(Thread.java:748)
  1> [2017-10-14T16:43:29,258][INFO ][o.e.c.m.MetaDataIndexUpgradeServiceTests] [testPluginUpgrade]: before test
  1> [2017-10-14T16:43:29,263][INFO ][o.e.c.m.MetaDataIndexUpgradeServiceTests] [testPluginUpgrade]: after test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this happens because IndexAnalyzers iterates over the analyzers/normalizers when in close(). Go ahead and add back the empty map, but please add a comment noting the reason?

@@ -136,7 +137,24 @@ private void checkMappingsCompatibility(IndexMetaData indexMetaData) {
// We cannot instantiate real analysis server at this point because the node might not have
// been started yet. However, we don't really need real analyzers at this stage - so we can fake it
IndexSettings indexSettings = new IndexSettings(indexMetaData, this.settings);
SimilarityService similarityService = new SimilarityService(indexSettings, null, Collections.emptyMap());
final Map<String, SimilarityProvider.Factory> similarityMap = new AbstractMap<String, SimilarityProvider.Factory>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment here that having a dummy map works because we assume any similarity providers were known before the upgrade, so allowing any key below is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did test the patch with a elasticsearch server without the custom similarity installed. The server starts but does not recover the index with an appropriate error message. I did not test restoring a snapshot from an old version. But as far as I understand the situation, we do not assume all used similarities are actually known here, but just defer the error to a point when we actually know all available similarities.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defer is what I meant by "assume". We allow any similarity name to be looked up without error. We don't actually use it, we just need to ensure the lookup does not fail. This is ok because we assume whatever was present when ES last shut down had all known similarities.

@xabbu42
Copy link
Contributor Author

xabbu42 commented Oct 30, 2017

Just to be clear, I'm waiting on further input here for both the requested changes.

@rjernst
Copy link
Member

rjernst commented Nov 10, 2017

@xabbu42 Sorry for the delayed response. Could you please update this PR as per the new comments?

@xabbu42
Copy link
Contributor Author

xabbu42 commented Nov 11, 2017

@rjernst no problem, I just wanted to make sure nobody is waiting on me. I hope the updated PR is ok now.

@cbuescher cbuescher added the :Core/Infra/Plugins Plugin API and infrastructure label Nov 16, 2017
@rjernst
Copy link
Member

rjernst commented Nov 27, 2017

@elasticmachine test this please

@rjernst
Copy link
Member

rjernst commented Nov 28, 2017

@xabbu42 Can you fix the tabs? They should be spaces:

23:25:22 Execution failed for task ':core:forbiddenPatterns'.
23:25:22 > Found invalid patterns:
23:25:22   - tab on line 159 of core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java
23:25:22   - tab on line 160 of core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java
23:25:22   - tab on line 181 of core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java
23:25:22   - tab on line 182 of core/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java

@xabbu42
Copy link
Contributor Author

xabbu42 commented Nov 29, 2017

Ups sorry about that, its fixed now.

@rjernst
Copy link
Member

rjernst commented Dec 5, 2017

@elasticmachine test this please

1 similar comment
@rjernst
Copy link
Member

rjernst commented Dec 21, 2017

@elasticmachine test this please

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@rjernst
Copy link
Member

rjernst commented Dec 22, 2017

@elasticmachine test this please

1 similar comment
@rjernst
Copy link
Member

rjernst commented Dec 22, 2017

@elasticmachine test this please

@rjernst rjernst merged commit 06d1ed8 into elastic:master Jan 9, 2018
rjernst pushed a commit that referenced this pull request Jan 9, 2018
Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350
@rjernst
Copy link
Member

rjernst commented Jan 9, 2018

Thanks @xabbu42

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 9, 2018
* master:
  Use Gradle wrapper when building BWC
  Painless: Add a simple cache for whitelist methods and fields. (elastic#28142)
  Fix upgrading indices which use a custom similarity plugin. (elastic#26985)
  Fix Licenses values for CDDL and Custom URL (elastic#27999)
  Cleanup TcpChannelFactory and remove classes (elastic#28102)
  Fix expected plugins test for transport-nio
  [Docs] Fix Date Math example descriptions (elastic#28125)
  Fail rollover if duplicated alias found in template (elastic#28110)
  Avoid concurrent snapshot finalizations when deleting an INIT snapshot (elastic#28078)
  Deprecate `isShardsAcked()` in favour of `isShardsAcknowledged()` (elastic#27819)
  [TEST] Wait for replicas to be allocated before shrinking
  Use the underlying connection version for CCS connections  (elastic#28093)
  test: do not use asn fields
  Test: Add assumeFalse for test that cannot pass on windows
  Clarify reproduce info on Windows
  Remove out-of-date projectile file
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 9, 2018
* master: (27 commits)
  Declare empty package dirs as output dirs
  Consistent updates of IndexShardSnapshotStatus (elastic#28130)
  Fix Gradle wrapper usage on Windows when building BWC (elastic#28146)
  [Docs] Fix some typos in comments (elastic#28098)
  Use Gradle wrapper when building BWC
  Painless: Add a simple cache for whitelist methods and fields. (elastic#28142)
  Fix upgrading indices which use a custom similarity plugin. (elastic#26985)
  Fix Licenses values for CDDL and Custom URL (elastic#27999)
  Cleanup TcpChannelFactory and remove classes (elastic#28102)
  Fix expected plugins test for transport-nio
  [Docs] Fix Date Math example descriptions (elastic#28125)
  Fail rollover if duplicated alias found in template (elastic#28110)
  Avoid concurrent snapshot finalizations when deleting an INIT snapshot (elastic#28078)
  Deprecate `isShardsAcked()` in favour of `isShardsAcknowledged()` (elastic#27819)
  [TEST] Wait for replicas to be allocated before shrinking
  Use the underlying connection version for CCS connections  (elastic#28093)
  test: do not use asn fields
  Test: Add assumeFalse for test that cannot pass on windows
  Clarify reproduce info on Windows
  Remove out-of-date projectile file
  ...
@rjernst rjernst added v6.2.0 and removed v6.3.0 labels Jan 15, 2018
rjernst pushed a commit that referenced this pull request Mar 1, 2018
Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350
relates #26985
@rjernst rjernst added the v5.6.9 label Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants